// 异常考勤记录
var anlogGridColumns = [
    {
        id: 'userName',
        title: '姓名',
        type: 'string',
        columnClass: 'text-center',
    },
    {
        id: 'userId',
        title: '工号',
        type: 'string',
        columnClass: 'text-center',
    },
    {
        id: 'attendanceDate',
        title: '考勤日期',
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var date = new Date(record.attendanceDate);
            var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd");
            return content;
        }
    },
    {
        id: 'attendanceTime',
        title: '上班刷卡',
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var date = new Date(record.attendanceTime);
            var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd hh:mm");
            return content;
        }
    },
    {
        id: 'quitTime',
        title: '下班刷卡',
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var date = new Date(record.quitTime);
            var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd hh:mm");
            return content;
        }
    },
    {
        id: 'containedStatus',
        title: '考勤结果',
        type: 'string',
        columnClass: 'text-center',
    },
    {
        id: 'descError',
        title: '异常说明',
        type: 'string',
        columnClass: 'text-center',
    },
    {
        id: 'operation',
        title: '操作',
        width: 60,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '';
            if (record.containedStatus && record.containedStatus.length > 0) {
                content += '<button class="btn btn-xs btn-primary" onclick="cancelErrorHander(\'' + record.id + '\');"><i class="icon-eye-open"></i>  消除异常</button>';
            }
            return content;
        }
    },
    {
        id: 'leaveCode',
        title: '请假单',
        type: 'string',
        columnClass: 'text-center',
        hideType: 'lg|md|sm|xs'
    },
    {
        id: 'businessTripCode',
        title: '出差公干单',
        type: 'string',
        columnClass: 'text-center',
        hideType: 'lg|md|sm|xs'
    },
    {
        id: 'forgetBrushCode',
        title: '忘记刷卡单',
        type: 'string',
        columnClass: 'text-center',
        hideType: 'lg|md|sm|xs'
    },
];

// var anlogGridOption = {
//   lang: 'zh-cn',
//   ajaxLoad: false,
//   exportFileName: '异常考勤记录',
//   datas: [{
//     userName: '张三',
//     userId: '90000',
//     attendTime: '2010-01-01',
//     startTime: '08:00',
//     endTime: '18:00',
//     attend: '异常',
//     leave: '<a href="#">NJQJ2018010219291900</a>'+'/'+'<a href="#">NJQJ2018010219291900</a>',
//     trip: '<a href="#">NJCC2018010219291900</a>'+'/'+'<a href="#">NJCC2018010219291900</a>',
//     forget: '<a href="#">NJWJ2018010219291900</a>'+'/'+'<a href="#">NJWJ2018010219291900</a>'
//   }],
//   columns: anlogGridColumns,
//   gridContainer: 'anlogDataGird',
//   toolbarContainer: 'anlogGridToolBarContainer',
//   extraWidth: 20,
//   tools : '',
//   pageSize: 10,
//   pageSizeLimit: [10, 20]
// };
// var anlogGird = $.fn.dlshouwen.grid.init(anlogGridOption);
// $(function () {
//   anlogGird.load();
// });
var $$scope;
var $CertusFormAjax;
var dataInitPub;

function cancelErrorHander(id) {

  layer.prompt({
    title: '填写理由，并确认',
    formType: 2
  }, function (text, index) {


      //向 后台 请求 处理 异常
      $CertusFormAjax.ajax("cancelErrorHander", {
          id: id,humanErrorDesc:text
      }, function (res) {
          dataInitPub.refresh(true);
          layer.close(index);
          layer.msg(res.data);
      })
  }, function (text, index) {
      layer.close(index);
      layer.msg('理由：' + text);

    });

}